<?php
namespace wechat;

class User extends Base{
	
	/**
	* 微信网页授权获取用户信息 	2017-03-09
	*/
	public function getuserinfo($openid,$access_token,$attach = array()){
		$url = "https://api.weixin.qq.com/sns/userinfo?access_token=$access_token&openid=$openid&lang=zh_CN";
		$result = https_request($url);
		
		!isset($attach['uid']) && $attach['uid'] = 0;
		apilog($attach['uid'],'wechat','getuserinfo',$url,'',$result);
		
		return $result;
	}
	
	
	/**
	* 通过OpenID来获取用户基本信息 	2017-10-16
	*/
	public function getbyopenid($openid,$access_token,$attach = array()){
		$url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=$access_token&openid=$openid&lang=zh_CN";
		$result = https_request($url);
		
		isset($attach['uid']) && $attach['uid'] = 0;
		apilog($attach['uid'],'wechat','getuserinfobyopenid', $url, '', $result);
		
		return $result;
	}
}